home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / frac3.doc < prev    next >
Text File  |  1995-03-31  |  2KB  |  39 lines

  1. (Comp.sys.handhelds) 
  2. Item: 2826 by koslowj at math.ksu.edu 
  3. Author: [Juergen Koslowski] 
  4.   Subj: NEW2Q, fractions 
  5.   Date: Thu Apr 18 1991 
  6.  
  7. The recently posted program NEW2Q besides being rather long and displaying an 
  8. unfortunate mix of RPL and "algebraic" notation doesn't quite work as 
  9. advertised.  The fraction returned for "e" and "7" is `23225/8544', which when 
  10. subtracted from "e" leaves a result with 8 zeros after the decimal point. 
  11. However, the fraction `15062/5541' is simpler and results in an error with 7 
  12. zeros after the decimal point. 
  13.  
  14. The following program is much shorter and does correctly find `15062/5541'.  It 
  15. handles negative decimals better than NEW2Q, and it consistently returns 
  16. fractions of the form `a/b', even if the argument in level 1 is "0" or "1". 
  17. (If you eliminate the "NEG ALOG" part, you can explicitly enter the desired 
  18. error on level 1, rather than the desired number of zeros after the decimal 
  19. point.  In essentially this form I posted the program to the HP28 list in the 
  20. Fall of 1989.) 
  21.  
  22. Drawbacks: Occasionally, the program can take a long time to finish.  Example: 
  23. "pi" and "11". 
  24.  
  25. [Note: It takes 23.45 seconds.  NEW2Q takes 1.51 seconds and gets the same 
  26. answer!  The ->Q function takes .66 seconds.  The only program on this disk 
  27. that beats ->Q is D2F, which takes 0.45 seconds.  -jkh-] 
  28.  
  29. Advantages: The simplest fraction approximating the decimal to the given 
  30. accuracy is guaranteed to be found.  [Ditto for DEC2FRAC.  -jkh-] 
  31.  
  32. References: Section 4.5 in "Concrete Mathematics," by R. L. Graham, D. E. 
  33. Knuth, and O. Patashnik, Addison Wesley, 1989 
  34.  
  35. Enjoy,          J"urgen Koslowski 
  36.                 Department of Mathematics 
  37.                 Kansas State University 
  38.                 koslowj@math.ksu.edu 
  39.